<template>
	<!-- 经销商信息审核 -->
	<div>
		<!-- 搜索 -->
		<commonSearch @filterChange="changeHandle" @onCollapse="collapseHandle" />
		<!-- table -->
		<FilterTable
			ref="table"
			:columns="columns"
			:isSelectColumn="isSelectColumn"
			:fetchapi="fetchApi"
			:params="fetchParams"
			:datakey="'records'"
			columnsRef='origin_originInfo_review_index_01'
			:onColumnsChange="columns => this.columns = columns"
		>
			<!-- <template slot="controls">
				<el-button size="small" type="primary" icon="el-icon-plus" @click="drawerHandle(null,'add')">新增</el-button>
			</template> -->
		</FilterTable>
		<Drawer
			:visible.sync="visibleDrawer"
			title="经销商信息"
			destroyOnClose
			:containerStyle="{width:'70vw', minWidth:'1000px', height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
		>
			<dealerForm v-model="initData"  @close="viewDrawerClose" />
		</Drawer>
		<Drawer
			:visible.sync="visibleDrawerView"
			title="经销商信息"
			destroyOnClose
			:containerStyle="{width:'70vw', minWidth:'1000px', height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
		>
			<dealerFormView v-model="initData"  @close="viewDrawerClose"/>
		</Drawer>
		<Drawer
			:visible.sync="visibleExamineDrawer"
			title="经销商财务信息审核"
			destroyOnClose
			:containerStyle="{width:'70vw', minWidth:'1000px', height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
		>
			<examineForm v-model="initData"  @close="drawerClose" />
		</Drawer>
	</div>
</template>
<script>
	import commonSearch from '../commonSearch/index'
	import dealerForm from '../dealerForm'
	import dealerFormView from '../dealerFormView'
	import examineForm from '../dealerFormBank/examineBankIndex'
	import { dictionary } from '@/utils/dictMixin';
	import { region } from '@/api/cms-common/region';//行政区域

	import { findPage } from '@/api/cms-api/origin/originInfo';
	import * as types from '@/api/cms-api/origin/originInfo/types';
	import { DICT_CODE } from '@/api/cms-api/origin/commonDealerType';		//经销商类型工具类

	export default {
	  name:'bankCheck',
		mixins: [dictionary,region],
		components: {
			commonSearch,dealerForm,examineForm,dealerFormView
		},
		data() {
			return {
				isSelectColumn: false,
				visibleDrawer: false,
				visibleDrawerView:false,
				visibleExamineDrawer: false,
				columns: this.creatHeader(),
				initData: {},
				fetchApi: findPage, //ipa 接口
				// fetchParams: {queryByOrgCode:types.QUERY_BY_ORG_VALUE,auditStatus:types.DEALER_INFO_STATUS_SUBMITTED}, //参数
				fetchParams: {isChecked:10221004}, //参数
				types:types
			};
		},
		mounted() {
			this.BaseTable = this.$refs.table.$refs.pageTable;
		},
		methods: {
			//获取状态（需要显示的）
			getAuditTypes(){
				return [types.DEALER_INFO_STATUS_SUBMITTED];
			},
			//搜索获取数据
			changeHandle(val) {
				val.isChecked=10221004;
				// this.fetchParams = Object.assign({queryByOrgCode:types.QUERY_BY_ORG_VALUE,auditStatus:types.DEALER_INFO_STATUS_SUBMITTED},val);
				this.fetchParams = Object.assign({auditStatusList:this.getAuditTypes().join(",")},val);
			},
			//查看
			viewDrawerHandle(row, type) {
				this.initData = {
					type: type, //add/edit/show
					examineType:'show',//设置主表单内容为只读
					isExamine:false,//打开审核按钮和输入框
					formType:types.DEALER_INFO_FORM_STATUS_EXAMINE_OEM,
					id: row.dealerAttachId  //表主键
				};
				if(type == 'show'){
					this.visibleDrawerView = true;
				}else{
					this.visibleDrawer = true;
				}
			},
			//查看关闭
			viewDrawerClose(type) {
				this.visibleDrawer = false;
				this.visibleDrawerView = false;
				if (type === 'refresh') {
					// 重新加载
					this.fetchParams = { ...this.fetchParams };
				}
			},
			//审核页面
			drawerHandle(row, type) {
				this.initData = {
					type: type, //add/edit/show
					examineType:'edit',//设置主表单内容为只读
					isExamine:true,//打开审核按钮和输入框
					id: row.dealerAttachId  //表主键
				};
				this.visibleExamineDrawer = true;
			},
			//审核关闭
			drawerClose(type) {
				this.visibleExamineDrawer = false;
				if (type === 'refresh') {
					// 重新加载
					this.fetchParams = { ...this.fetchParams };
				}
			},
			collapseHandle() {
				this.$nextTick(() => {
					this.BaseTable.EXECUTE_RESET_HEIGHT();
				});
			},
			//table表头和数据源
			creatHeader() {
				return [
					{ title: '序号', dataIndex: 'index', width: 80, sorter: true,
						render: props => {
							return <span>{props.row.index + 1}</span>;
						}
					},
					{ title: '操作', dataIndex: 'column-action', width: 100, fixed: 'left',
						render: (props, h) => {
							let editBtn,editBtnEnd;
							if(props.row.isChecked == 10221004){
								editBtn = (
									<el-button size="mini" type="text" onClick={() => this.drawerHandle(props.row,'show')}>
									审核
									</el-button>
								);
								editBtnEnd = (<el-divider direction="vertical" />);
							}
							return (
								<div>
									{editBtn}
									{editBtnEnd}
									<el-button size="mini" type="text" onClick={() => this.viewDrawerHandle(props.row,'show')}>
									明细
									</el-button>
								</div>
							);
						}
					},
					{ title: '状态', dataIndex: 'auditStatus', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.auditStatus, '2551')}</span>;
						}
					},
					{ title: '公司全称', dataIndex: 'dealerName', sorter: true },
					// { title: '临时代码', dataIndex: 'x1', sorter: true },
					{ title: '经销商代码', dataIndex: 'dealerCode', sorter: true },
					{ title: '经销商简称', dataIndex: 'dealerShortname', sorter: true },

					{ title: '渠道类型', dataIndex: 'dealerType', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.dealerType, DICT_CODE)}</span>;
						}
					},
					{ title: '经销商级别', dataIndex: 'shopLevel', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.shopLevel, '2540')}</span>;
						}
					},
					{ title: '店面等级', dataIndex: 'constructLevel', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.constructLevel, '2554')}</span>;
						}
					},//SALE_LEVEL？销售店面级别
					{ title: '展厅级别', dataIndex: 'saleLevel', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.saleLevel, '2542')}</span>;
						}
					},
					{ title: '售后级别', dataIndex: 'serviceLevel', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.serviceLevel, '2543')}</span>;
						}
					},
					{ title: '事业部', dataIndex: 'deptName', sorter: true,width:200},
					{ title: '办事处', dataIndex: 'officeName', sorter: true },
					{ title: '省份', dataIndex: 'provinceId', sorter: true,
						render: props => {
							return <span>{this.createRegionText(props.row.provinceId)}</span>;
						}
					},
					{ title: '城市', dataIndex: 'cityId', sorter: true,
						render: props => {
							return <span>{this.createRegionText(props.row.cityId)}</span>;
						}
					},
					{ title: '县区', dataIndex: 'districtId', sorter: true,
						render: props => {
							return <span>{this.createRegionText(props.row.districtId)}</span>;
						}
					},
					{ title: '系统管理员', dataIndex: 'systemManager', sorter: true },
					{ title: '管理员电话', dataIndex: 'sysManagerPhone', sorter: true },
					{ title: '保证金金额', dataIndex: 'cashDeposit', numberFormat: true, sorter: true },
					{ title: '启用标记', dataIndex: 'status', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.status, '1003')}</span>;
						}
					},
					{ title: '经营状态', dataIndex: 'dealerStatus', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.dealerStatus, '2552')}</span>;
						}
					},
					{ title: '是否启用中央补贴', dataIndex: 'isRegionalAllowance', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.isRegionalAllowance, '1004')}</span>;
						}
					},
					{ title: '是否启用地方补贴', dataIndex: 'isCentrelAllowance', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.isCentrelAllowance, '1004')}</span>;
						}
					},
					{ title: '开票是否包含地方补贴', dataIndex: 'isContainRAllowance', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.isContainRAllowance, '1004')}</span>;
						}
					},
					{ title: '是否黑名单', dataIndex: 'isBlack', sorter: true },
					{ title: '财务审核状态', dataIndex: 'isChecked',dictItems:this.createDictList('1022'), sorter: true },
				];
			},
		},
	};
</script>

<style lang="less" scoped>
</style>
